﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Autofac.Extras.DynamicProxy;
using log4net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Session;
using Suk.Interface;
using Suk.Web.Models;
using Suk.Models;
using Microsoft.AspNetCore.Http;
using Suk.Common;

namespace Suk.Web.Controllers
{
    [Intercept(typeof(LogInterceptor))]
    public class HomeController : Controller
    {
        //服务依赖
        public IHomeService _IHomeService { get; set; }
        public IBll _IBll { get; set; }
        public ILog log { get; set; }


        public HomeController()
        {
        }
        //public HomeController(ILog logger)
        //{
        //    log = logger;
        //}

        public IActionResult Index()
         {
            log.Error("框架首页加载日志");

            Console.WriteLine("session  " + this.HttpContext.Session.Id);

            string val = this.HttpContext.Session.GetString("session");

            Console.WriteLine("UserName  " + val);

            RedisHelper red = new RedisHelper();
            red.Redis.StringSet("test", "session" + this.HttpContext.Session.Id);
            string xx = red.Redis.StringGet("test");
            Console.WriteLine("session  " + this.HttpContext.Session.Id);

            this.HttpContext.Session.SetString("sex", "男");
            this.HttpContext.Session.SetString("UserName", "suking");

            this.HttpContext.Session.SetString("PassWord", "1234567");

            //a = this.HttpContext.Session.GetString("UserName");
            string b = this.HttpContext.Session.GetString("PassWord");
            string c = this.HttpContext.Session.GetString("PassWord1");
            log.Error("框架首页加载日志");


            return View();
        }

       


        public JsonResult tableData1(decimal curr, decimal nums, decimal token, decimal id, string code)
        {


            //throw new Exception();
            IBll homebll = Startup.GetFromFac<IBll>();

            homebll.Save();


            string xx = _IBll.Save();
            string x = Request.Query["code1"]; //  
                                               //Order o = new Order();
                                               //_IHomeService.Insert(o);
            var data = _IHomeService.FindEntity();

            return Json(data);
        }

        public IActionResult tablethead()
        {
            ViewData["Message"] = "userpassword";

            string xx = null;
            xx = xx.ToString();
            return View();
        }
        public IActionResult tableform()
        {
            ViewData["Message"] = "userpassword";

            return View();
        }
        public IActionResult tablecellEdit()
        {
            ViewData["Message"] = "userpassword";

            return View();
        }
        public IActionResult tabletotalRow()
        {
            ViewData["Message"] = "userpassword";

            return View();
        }
        public IActionResult tablestatic()
        {
            ViewData["Message"] = "userpassword";

            return View();
        }
        public IActionResult userpassword()
        {
            ViewData["Message"] = "userpassword";

            return View();
        }
        public IActionResult userinfo()
        {
            ViewData["Message"] = "userinfo";

            return View();
        }
        public IActionResult tree()
        {
            ViewData["Message"] = "tree";

            return View();
        }
        public IActionResult transfer()
        {
            ViewData["Message"] = "transfer";

            return View();
        }
        public IActionResult upload()
        {
            ViewData["Message"] = "upload";

            return View();
        }
        public IActionResult layer()
        {
            ViewData["Message"] = "layer";

            return View();
        }
        public IActionResult timeline()
        {
            ViewData["Message"] = "timeline";

            return View();
        }
        public IActionResult Panel()
        {
            ViewData["Message"] = "Panel";

            return View();
        }
        public IActionResult FormNav()
        {
            ViewData["Message"] = "FormNav";

            return View();
        }

        public IActionResult FormButton()
        {
            ViewData["Message"] = "FormButton";

            return View();
        }

        public IActionResult Form()
        {
            ViewData["Message"] = "Form";

            return View();
        }


        public IActionResult Login()
        {

            return View();
        }
        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";

            return View();
        }

        public IActionResult Contact()
        {
            ViewData["Message"] = "Your contact page.";

            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }







    }
}
